from rest_framework import serializers

# serializers.ModelSerializer
# serializers.Serializer
# 因为有模型 优先使用 ModelSerializer
from areas.models import Area

# 省对应的序列化器
class AreaSerializer(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ['id','name']


# 市对应的序列化器
class SubsAreaSerializer(serializers.ModelSerializer):

    subs = AreaSerializer(many=True)

    class Meta:
        model = Area
        fields = ['subs','id','name']
































